export function transformTemplate(code: any) {
  console.log(code, "code");
  const { content } = code;

  const _template = content.template ?? "";
  const _style = `<style>
    ${content.css}
  </style>`;
  let _script = "";

  if (content.js) {
    const js = content.js
      .toString()
      .replace(
        /^function\s+generate\s*\(\)\s*{\s*return\s*{([\s\S]*)};\s*}$/g,
        "$1",
      );
    // console.log(_script, '_script');

    _script = `<script>
      export default {
        ${js}
      }
    </script>`;
  }

  const allTemplate = `
    ${_template}
    ${_script}
    ${_style}
  `;

  return allTemplate;
}
